package com.byq.mm.smartlib.obd.commands.fuel;

import com.byq.mm.smartlib.obd.commands.AbstractObdCommand;
import com.byq.mm.smartlib.obd.enums.AvailableCommandNames;


/** * Get fuel level in percentage */
public class FuelLevelObdCommand extends AbstractObdCommand {
	private float fuelLevel = 0f;

	/** * @param command */
	public FuelLevelObdCommand() {
		super("01 2F");
	} /*           
	 * * (non-Javadoc) * * @see
	 * eu.lighthouselabs.obd.commands.ObdCommand#getFormattedResult()
	 */

	@Override
	public String getFormattedResult() {
		if (!"NODATA".equals(getResult())) {
			fuelLevel = 100.0f * buffer.get(2) / 255.0f;
		}
		return String.format("%.1f%s", fuelLevel, "%");
	}

	@Override
	public String getName() {
		return AvailableCommandNames.FUEL_LEVEL.getValue();
	}

	@Override
	public String getRequestKey() {
		// TODO Auto-generated method stub
		return "01 2F";
	}
}
